package cn.botter.auth.entity;

import lombok.Data;

@Data

/**
 * 自定义封装返回结果类
 */
public class Result<T> {
    private Boolean success;
    private Integer code;
    private String message;
    private T data;

    public static Result OK(){
        Result result = new Result();
        result.setSuccess(false);
        result.setCode(ResultCodeEnum.FAILED.getCode());
        result.setMessage(ResultCodeEnum.FAILED.getDesc());
        return result;
    }

    public static <T> Result OK(T date){
        Result result = new Result();
        result.setSuccess(true);
        result.setCode(ResultCodeEnum.SUCCESS.getCode());
        result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
        result.setData(date);
        return result;
    }
    public static <T> Result OK( String message,T date){
        Result result = new Result();
        result.setSuccess(true);
        result.setCode(ResultCodeEnum.SUCCESS.getCode());
        result.setMessage(message);
        result.setData(date);
        return result;
    }
    public static <T> Result OK(Integer code, String message,T date){
        Result result = new Result();
        result.setSuccess(true);
        result.setCode(code);
        result.setMessage(message);
        result.setData(date);
        return result;
    }
    public static <T> Result OK(Boolean success, Integer code, String message, T data){
        Result result = new Result();
        result.setSuccess(success);
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static Result FAILED(){
        Result result = new Result();
        result.setSuccess(false);
        result.setCode(ResultCodeEnum.FAILED.getCode());
        result.setMessage(ResultCodeEnum.FAILED.getDesc());
        return result;
    }

    public static <T> Result FAILED(T date){
        Result result = new Result();
        result.setSuccess(false);
        result.setCode(ResultCodeEnum.FAILED.getCode());
        result.setMessage(ResultCodeEnum.FAILED.getDesc());
        result.setData(date);
        return result;
    }
    public static <T> Result FAILED( String message,T date){
        Result result = new Result();
        result.setSuccess(false);
        result.setCode(ResultCodeEnum.FAILED.getCode());
        result.setMessage(message);
        result.setData(date);
        return result;
    }
    public static <T> Result FAILED(Integer code, String message,T date){
        Result result = new Result();
        result.setSuccess(false);
        result.setCode(code);
        result.setMessage(message);
        result.setData(date);
        return result;
    }
    public static <T> Result FAILED(Boolean success, Integer code, String message, T data){
        Result result = new Result();
        result.setSuccess(success);
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
}
